// 部门 人员 审核搜索条
<template>

   
   <div class="auditing-search-bar">

        <l-item-block :title='mod.label' v-for='mod of mods' :key='mod.key'>
            <component :is="mod.component" v-model="tableReqParams[mod.key]" :conf='mod.conf'></component>
        </l-item-block>

        <l-item-block :title='"订单归属"'>

        <Poptip trigger="click" content="content" placement= 'right-start'>

            <ButtonGroup>
                <Button size='small' v-for='(name, index) of departmentBtns' :key='index'> {{name}} </Button>
            </ButtonGroup>
            
            <div class="content department-content" slot='content'>
                <l-department-list :companys='companys' @select='selectDepartment'></l-department-list>
            </div>

        </Poptip>

    </l-item-block>
    
        <l-item-block :key='"search"'>
            <Button long size='small' type='primary' @click='search'> 
                搜索
            </Button>
        </l-item-block>
       
       
   </div>
    
</template>

<script lang='ts'>
import {Component, Prop, Vue} from 'vue-property-decorator'
import itemBlock from '@/components/ivew_components/table_tools_item_block/index.vue'
import {mapState, mapMutations} from 'vuex'
import parckComponent from '@/components/ivew_components/parck_components/index'
import departmentList from '@/components/ivew_components/organization_select/department_list/index.vue'


@Component({
    
    components:{
        'l-item-block': itemBlock,
        'l-department-list': departmentList
    },
    
    computed: {
         ...mapState('organizationStore', ['companys']),
        ...mapState('auditingStore', ['tableReqParams'])
    }
    
})
export default class auditingSearchBar extends Vue{
    name:string = 'auditing-search-bar'

    tableReqParams:auditingInf.reqData
    companys:any

    mods = [

        {
            label: '申请类型',
            key: 'kind',
            component: parckComponent('select'),
            conf: {
                options: [

                    {
                        label:'全部',
                        value: 4000
                    },
                    {
                        label: '公司审核',
                        value: 2000
                    },
                    {
                        label: '部门审核',
                        value: 1000
                    },
                    {
                        label: '人员审核',
                        value: 3000
                    }
                    
                ]
            }
        },

        {
            label: '审核状态',
            key: 'status',
            component: parckComponent('select'),
            conf: {
                options: [

                    {
                        label:'全部',
                        value: 4
                    },
                    {
                        label: '待审核',
                        value: 1
                    },
                    {
                        label: '审核通过',
                        value: 2
                    },
                    {
                        label: '审核驳回',
                        value: 3
                    }
                    
                ]
            }
        },

        {
            label: '审核ID',
            key: 'jobId',
            component: parckComponent('input'),
            conf: {
                clearable:true
            }
        }
        
    ]
    

       // 部门按键
    get departmentBtns(){
        let tableReqParams = this.tableReqParams;
        let map = ['company', 'department'];
        let cache = [];
        
        map.forEach(key =>{

            if(tableReqParams[key]){
                cache.push(tableReqParams[key])
            }
            
        })
        
        if(!cache.length){
            cache.push('总公司')
        }
        
        return cache
    }

    // 缓存部门选中项数据
    selectDepartment(currentData){
        let {company, department}  = currentData

        this.tableReqParams['company'] = company;
        this.tableReqParams['department'] = department;
    }

    // 提交搜索
    search(){

        this.$store.dispatch('request', {
            url: 'get/auditings',
            data: {}
        })
    }

    // 刷新列表
    created(){
        this.$store.dispatch('organizationStore/initOrganization').then(success =>{})
    }
    
}


</script>

<style scoped lang='scss'>

</style>